<template>
	<view class="container">
		<formItem label="姓名" v-model="form.name" disabled="true"/>
		<formItem label="性别" v-model="form.sex" disabled="true"/>
		<formItem label="联系电话" v-model="form.tel" disabled="true"/>
		<formItem label="员工编号" v-model="form.employeeNumber" disabled="true"/>
		<formItem label="联系地址" v-model="form.contactAddress" disabled="true"/>
		<formItem label="EMAIL" v-model="form.email" disabled="true"/>
		<formItem label="证件类型" v-model="form.documentType" disabled="true"/>
		<formItem label="证件号码" v-model="form.idNumber" disabled="true"/>
		<formItem label="入职日期" v-model="form.entryDate" disabled="true"/>
		<formItem label="预约自动分配" isSlot="true" slotName="switchModel">
			<template #switchModel>
				<view>
					<u-switch v-model="form.autoAssignment" disabled="true" @change="change"></u-switch>
				</view>
			</template>				
		</formItem>
		<view>
			<u-button  type="error"  @click="exitLogin">退出登陆</u-button>
		</view>
	</view>
</template>

<script>
	import formItem from '../../components/lt-formItem/index.vue';
	import { getPersonalInfo,updatePersonalInfo } from '@/api/common.js';
	import storage from '@/utils/Stroage.js'
	export default{
		components:{
			formItem
		},
		async mounted(){
			let res = await getPersonalInfo()
			this.form = res.rows
			// this.form.autoAssignment = this.form.autoAssignment === '0' ? false : true
			// console.log(res)
		},
		data(){
			return{
				form:{
					autoAssignment:false
				},
			}
		},
		watch:{
			'form.name':{
				deep:true,
				handler:(val)=>{
					console.log('父组件',val)
				}
			}
		},
		methods:{
			change(val){
				console.log(val)
				let params = {
					autoAssignment:val?'1':'0',
					mobile:this.form.tel
				}
				updatePersonalInfo(params).then(res=>{
					console.log('res',res)
				})
			},
			exitLogin(){
				storage.clear()
				this.$navTo.togo('/pages/login/index')
			}
		}
	}
</script>

<style>
</style>
